//
//  CategorySelectListViewModel.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 02.04.25.
//

import Foundation
class CategorySelectListViewModel : KoiAccountingBaseViewModel {
    
    @Published var categoryList = Array<AccountingCategory>()
    
    func loadCategorys(selectedCategory: AccountingCategory) {
        DispatchQueue.global(qos: .background).async {
            var result = KoiAccountingDB.standard.getCategoryDao().getCategoryByType(uid: self.uid, bookId: self.bookId, type: selectedCategory.getCategoryType().rawValue)
            result.removeAll(where: { item in item.cid == selectedCategory.cid })
            DispatchQueue.main.async {
                self.categoryList = result
            }
        }
    }
}
